//
//  ZDFeedbackController.m
//  特种车调度
//
//  Created by 陈宇 on 15/9/10.
//
//

#import "ZDFeedbackController.h"
#import "BMAccountManager.h"

@interface ZDFeedbackController ()

@property (weak, nonatomic) IBOutlet UITextView *textView;
- (IBAction)okAction:(UIButton *)sender;

@end

@implementation ZDFeedbackController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (IBAction)okAction:(UIButton *)sender {
    NSString *content = _textView.text;
    if ([BMUtils isEmptyString:content]) {
        [self showHint:@"请输入内容!"];
        return;
    }
    BMRequest *request = [BMRequest requestWithPath:@"feedback/add.htm"];
    request.params = @{@"type": @(abs(kRoleType - 1)), @"content": content, (kRoleType ? @"diapatcherId" : @"ownerId"): @([BMAccountManager sharedInstance].user.ID)};
    [self showHudWithhint:kDefaultMessage];
    [[BMHttpTool sharedInstance] postWith:request finish:^(BMResponse *response, NSError *error) {
        [self hideHud];
        if (response.status == kResultOK) {
            [self showHint:@"意见反馈发送成功!"];
            [self.navigationController popViewControllerAnimated:YES];
        } else {
            [self showHint:@"意见反馈发送失败!"];
        }
    }];
}

@end
